Computer vision systems can be utilized to obtain precise dimensional measurements of scanned objects. Such systems may include a computer and a camera and optical system with a stage that is movable to allow the camera to follow the edge contour of an object that is being scanned. One exemplary prior art system that is commercially available is the QUICK VISION™ series of vision inspection machines and QVPAK™ software available from Mitutoyo America Corporation (MAC), located in Aurora, Ill.. This product includes a two-dimensional autotrace edge detection tool that is designed to detect points along a continuous edge contour of an object, and automatically move the stage as necessary to follow the contour beyond the limits of any single video image. A single video image often encompasses only a portion of the object being scanned, given the desired magnification, measurement resolution and physical size limitations of such systems. The two-dimensional autotrace edge detection tool helps to save time when the vision system is operated in a “learning” mode, where it is being programmed to measure various characteristics of a relatively long edge contour, which might cross multiple video images. Since this tool has the ability to determine or modify its trace path based upon edge contour information of a particular sample at run time, it also helps to avoid the run-time failures that occur with edge tools which rely on a fixed position and a pre-programmed edge configuration.
The two-dimensional autotrace edge detection tool operates according to an autotrace algorithm, as will be described in more detail below with respect to FIGS. 1A, 1B, and 1C. At the beginning of the autotrace algorithm, a user defines a tool. This initial tool definition includes for example, tool position, tool scanning direction, and scan line sampling interval. The various edge detection thresholds and polarity of the scanning direction and the edge transitions of the edge to be traced are automatically learned according to known methods. The polarity of the edge transition indicates whether the expected edge exhibits an intensity increase—dark to light—along the defined scanning direction, or an intensity decrease—light to dark—along the defined scanning direction. Using some or all of the above-mentioned information, two edge points are detected, as illustrated in FIG. 1A, where two scan lines S1A and S2A locate two edge points A1 and A2 along the edge of a target object TG. The scan lines are initially located a default distance D12 apart. The distance between scan lines is more generally called the scan line sampling interval herein.
In accordance with the autotrace algorithm, once the edge points A1 and A2 are located, the next edge location to be tried is determined based on the locations of the edge points A1 and A2, using a linear extrapolation. As illustrated in FIG. 1A, an extrapolation line E1A is shown through the edge points A1 and A2. A third scan line S3A is arranged perpendicular to E1A and at the distance D12 along the linear extrapolation line E1A from edge point A2. The third scan line S3A locates a third edge point A3. The edge point A3 is then used to form a new linear extrapolation line E2A through edge points A2 and A3, which is used to search for a new edge point. As this process continues, if the linear extrapolation method fails to locate a new edge point, then an additional linear extrapolation procedure is tried, as is described in more detail below with reference to FIG. 1B.
FIG. 1B illustrates an additional linear extrapolation procedure that is invoked if the procedures illustrated by FIG. 1A fail to locate an edge point. With regard to FIG. 1B, two scan lines S1B and S2B are shown to locate two edge points B1 and B2. A linear extrapolation line E1B is shown through the edge points B1 and B2. A third scan line S3B is shown along the extrapolation line E1B. As shown, scan line S3B does not locate a new edge point.
After scan line S3B does not locate a new edge point, the previous two detected edge points B1 and B2 are still used to determine the next edge point trial location. The same extrapolation is applied, although the scan line sampling interval used to extrapolate is halved. Thus, by halving the scan line sampling interval, the location of a new scan line S4B is determined. Since scan line S4B does not locate an edge point, the process is again repeated in that the scan line sampling interval is again halved, as illustrated by the location of scan line S5B. As shown, scan line S5B locates an edge point B3. Since a new edge point has been found, the edge point B3 replaces the edge point B1 that was used to determine the current edge point trial location, and the search process is reset to the procedures of FIG. 1A. Thus, a new extrapolation line E2B is shown through the edge points B2 and B3.
The halving process illustrated by FIG. 1B is repeated until either a predetermined minimum scan line sampling interval is reached, or an edge point is found. If the minimum scan line sampling interval is reached and no edge point is found, a rotation search will be invoked, as is described in more detail below with reference to FIG. 1C.
FIG. 1C illustrates a rotation search. In FIG. 1C, three edge points C1, C2, and C3 are shown along the edge of the target object TG. An extrapolation line E1C is shown through the edge points C2 and C3. A scan line S1C is shown through the edge point C3. It is presumed that the methods described above with reference to FIGS. 1A and 1B have been tried and have failed to locate an edge point beyond the edge point C3.
According to the procedures of FIG. 1C, the previous two detected edge points C2 and C3 are used to extrapolate one edge point trial location in the reversed direction to the previous searching direction along the edge contour. Conceptually, it is as though the entire edge locating tool/procedure is pivoted in the plane of the image around the last edge point located. It should be noted that because the entire tool is “pivoted”, the polarity of the tool edge scan will now be in the opposite direction relative to the part of the edge profile that has been already detected. Thus, a previously detected edge will not be detected again, due to the previously learned/defined polarity of the expected edge transition. Thus, a second scan line S2C is shown along the extrapolation line E1C in the reverse direction to the previous searching direction of the edge profile. It should be noted that in this the case shown in FIG. 1C the polarity of the tool scan is defined so that the search is for a change from object (dark) to background (light), and thus the scan line S2C does not locate an edge point since the transition in this case is from light to dark.
Since no edge point is detected by the scan line S2C, the tool scan's orientation will be rotated by a predetermined angular increment based on the radius of the rotation—(i.e. the scan line sample interval) and the length of the scan line such that it is impossible for an edge to fall between the end of one scan line and the start of the next incrementally rotated scan line. This process will be repeated until either an edge point is detected or the tool scan comes back to its original location. Thus, as illustrated in FIG. 1C, the tool scan's orientation is rotated by an angle increment of a predetermined amount, so as to produce a scan line S3C. This process is repeated for scan lines S4C, S5C, and S6C, the rotation of which are tangent to a circular rotation R1C. As shown, the scan line S6C locates a fourth edge point C4.
The edge point C4 then replaces the edge point C2, and the search process is reset to the procedures of FIG. 1A. Thus, a new extrapolation line E2C is shown through the edge points C3 and C4. If no new edge point had been found before the tool scan came back to its original location, the algorithm would report a failure.
The above procedures of FIGS. 1A, 1B, and 1C are effective for automatically tracing an edge of an image in a two dimensional image that is well-focused throughout. However, in practice it is desired to provide a similar type of autotrace tool to measure edges along a relatively long contour, which may extend through two or more image frames, according to the sizes of objects that are desired to be scanned, and/or for complex shaped parts. In such cases, there are often significant height changes along the contour, relative to the focal plane of the imaging system. Such height changes are also called depth changes herein, because they occur in a direction generally parallel to the direction of the depth of field of the imaging system. These height/depth changes can result in loss of focus and poor edge contrast. Poor edge contrast will cause the edge detection operations to fail or report an error—as it should for an image that cannot support reliable edge measurement. The inventors have also determined that simply augmenting the prior art two-dimensional edge tool with conventional auto-focus operations results in excessively slow edge tracing performance, particular for run mode applications. Thus, the inability of the existing tool to correct known problems via effective automated camera height adjustment is a limit on its usefulness. The present invention is directed toward improving on the above method by defining fast and effective systems and methods for determining the necessary changes in height and focus (e.g., along the Z axis) as the tool traces an edge contour in the three dimensional space, and by reusing as much data as possible so that time-consuming motions of the vision system are minimized.